function createFlyIo () {
  if(mpvuePlatform === 'wx') {
    const Fly = require('flyio/dist/npm/wx')
    return new Fly()
  }
  return null
}

export function get(url, params={}) {
  const fly = createFlyIo()
  if (fly) {
    return new Promise((resolve, reject) => {
      fly.get(url, params).then(res => {
        resolve(res)
      }).catch(err => {
        console.log(err)
        reject(err)
      })
    })
  }
}

export function post(url, params={}, token='') {
  const fly = createFlyIo()
  if (mpvue.getStorageSync('token') !== '') {
    fly.config.headers= {
      authorization: mpvue.getStorageSync('token')
    };
  }
  console.log(fly)
  if (fly) {
    return new Promise((resolve, reject) => {
      fly.post(url, params).then(res => {
        resolve(res)
      }).catch(err => {
        console.log(err)
        reject(err)
      })
    })
  }
}